{{response.files.append(URL(r=request,c='static',f='jquery.dataTables.min.js'))}}
{{response.files.append(URL(r=request,c='static',f='demo_table.css'))}}
{{extend 'layout.html'}}
<script>
jQuery(document).ready(function(){
   jQuery('.smarttable').dataTable();
});
</script>
{{if company:}}
<h1>Contacts at {{=link_company(company)}}</h1>

[<a href="#nil" onclick="jQuery('#form').slideToggle();">toggle</a>]
<div id="form">
<h2>New Contact Person</h2>
{{=form}}
</div>
{{else:}}
<h1>All Contacts</h1>
{{pass}}

<br /><br />
<table class="smarttable">
<thead>
  <tr>
    <th>Name</th><th>Role</th><th>Company</th><th>Action</th>
  </tr>
</thead>
<tbody>
{{for person in persons:}}
<tr>
<td>{{=person.name}}</td>
<td>{{=person.role}}</td>
<td>{{=cache.ram('c%s'%person.company, lambda:person.company.name,100)}}</td>
<td>{{=button('view','view_person',person.id)}}
{{=button('edit','edit_person',person.id)}}
{{=button('logs','list_logs',person.id)}}
{{=button('docs','list_docs',person.id)}}
{{=button('tasks','list_tasks',person.id)}}</td>
</tr>
{{pass}}
</tbody>
</table>
